<%--
  Created by IntelliJ IDEA.
  User: 62585
  Date: 2021/3/29
  Time: 10:33
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>ajax</title>
    <script type="text/javascript" src="script/jquery-1.7.2.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#ajax").click(function () {
                $.ajax({
                    url: "http://localhost:8080/json/AjaxServlet",
                    type: "GET",
                    dataType: "json",
                    success: function (data) {
                        $("#response").html(" ajax 编号：" + data.id + " , 姓名：" + data.name);
                    }
                });
            });
            $("#ajaxGet").click(function () {
                $.get("http://localhost:8080/json/AjaxServlet", function (data) {
                    $("#response").html(" ajax 编号：" + data.id + " , 姓名：" + data.name);
                }, "json")
            });

        })
    </script>
</head>
<body>
<div id="response"></div>
<button id="ajax" name="ajax">ajax</button>
<button id="ajaxGet" name="ajaxGet">ajaxGet</button>
</body>
</html>
